package com.diandian.backend.client.param;

import com.diandian.backend.client.constants.ClientConstant;
import com.diandian.base.boot.starter.exception.DefaultException;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.diandian.backend.client.dto.ClientClientInfoAddParamDTO;

import java.io.Serializable;
import java.util.Date;

public class ClientClientInfoAddParam implements Serializable {

	private String clientId;
	private String clientKey;
	private String clientSecret;
	private String remark;
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date startTime;
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date endTime;
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date createTime;
	private String createUserId;
	private String createUserName;
	private String status;

	public void check(){
		if(this.clientId == null || "".equals(this.clientId)){
			throw new DefaultException("clientId不能为空");
		}
		if(this.clientKey == null || "".equals(this.clientKey)){
			throw new DefaultException("clientKey不能为空");
		}
		if(this.clientSecret == null || "".equals(this.clientSecret)){
			throw new DefaultException("clientSecret不能为空");
		}
		if(this.startTime == null){
			throw new DefaultException("开始时间不能为空");
		}
		if(this.endTime == null){
			throw new DefaultException("截止时间不能为空");
		}
		if(this.status == null || "".equals(this.status)){
			status = ClientConstant.PERMISSION_STATUS_DISABLE;
		}
	}

	public ClientClientInfoAddParamDTO toDTO(){
		ClientClientInfoAddParamDTO dto = new ClientClientInfoAddParamDTO();
		dto.setClientId(this.clientId);
		dto.setClientKey(this.clientKey);
		dto.setClientSecret(this.clientSecret);
		dto.setRemark(this.remark);
		dto.setStartTime(this.startTime);
		dto.setEndTime(this.endTime);
		dto.setCreateTime(this.createTime);
		dto.setStatus(this.status);
		dto.setCreateUserId(this.createUserId);
		dto.setCreateUserName(this.createUserName);
		return dto;
	}

	public String getClientId() {
		return clientId;
	}
	public String setClientId(String clientId) {
		return this.clientId = clientId;
	}
	public String getClientKey() {
		return clientKey;
	}
	public String setClientKey(String clientKey) {
		return this.clientKey = clientKey;
	}
	public String getClientSecret() {
		return clientSecret;
	}
	public String setClientSecret(String clientSecret) {
		return this.clientSecret = clientSecret;
	}
	public String getRemark() {
		return remark;
	}
	public String setRemark(String remark) {
		return this.remark = remark;
	}
	public Date getStartTime() {
		return startTime;
	}
	public Date setStartTime(Date startTime) {
		return this.startTime = startTime;
	}
	public Date getEndTime() {
		return endTime;
	}
	public Date setEndTime(Date endTime) {
		return this.endTime = endTime;
	}
	public Date getCreateTime() {
		return createTime;
	}
	public Date setCreateTime(Date createTime) {
		return this.createTime = createTime;
	}
	public String getCreateUserId() {
		return createUserId;
	}
	public String setCreateUserId(String createUserId) {
		return this.createUserId = createUserId;
	}
	public String getCreateUserName() {
		return createUserName;
	}
	public String setCreateUserName(String createUserName) {
		return this.createUserName = createUserName;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
}
